//
//  JDCityShareViewController.swift
//  DragonWallet
//
//  Created by volantPig on 2024/5/7.
//

import UIKit
import JXSegmentedView

class JDCityShareViewController: JDBaseViewController {

    var mainTableView: UITableView?
    var dataSource: [String]?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.setupUIElements()
        self.getCurrentLocation()
        self.getNetData()
        // Do any additional setup after loading the view.
    }
    
    func setupUIElements() {
        
        self.mainTableView = UITableView(frame: .zero, style: .plain)
        self.view.addSubview(self.mainTableView!)
        self.mainTableView?.snp.makeConstraints({ make in
            make.left.right.equalTo(self.view)
            make.top.equalTo(self.view)//.offset(UIDevice().safeAreaInset.top)
            make.bottom.equalTo(self.view)
        })
        self.mainTableView?.backgroundColor = self.commonColor
        self.mainTableView?.delegate = self
        self.mainTableView?.dataSource = self
        self.mainTableView?.separatorStyle = .none
        self.mainTableView?.register(JDCityShareTableViewCell.self, forCellReuseIdentifier: "myCell")
    }
    
    func getNetData() {
        
        var params = [String: Any]()
//        params["onlineSign"] = JDLoginModel.default.onlineSign
        params["pageNumber"] = self.currentPage
        params["pageSize"] = 10
        params["lon"] = 120.58
        params["lat"] = 38.43
        
        JDNetWorkRequest(.cityShareList(params)) { responseStr in
            
            
            printLog("接口返回数据啊:\(responseStr)")
        } failure: { error in
            
        } error: { errorCode in
            
        }

        
    }
    
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}

extension JDCityShareViewController: UITableViewDelegate, UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 10
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "myCell") as? JDCityShareTableViewCell
        
        
        
        return cell!
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return UITableView.automaticDimension
    }
    
}

extension JDCityShareViewController: JXSegmentedListContainerViewListDelegate {
    func listView() -> UIView {
        return view
    }

    func listDidAppear() {
        
    }

    func listDidDisappear() {
    }
}
